import Vue from 'vue'
import VueX, { createLogger } from 'vuex'
import car from './modules/car.js'

Vue.use(VueX)

const store = new VueX.Store({
	state: {
		title: []
	},
	mutations: {
		setTitle(state, payload) {
			state.title = payload
		}
	},
	modules: {
		car
	},
	plugins: [createLogger()]
})


store.subscribe((mutation, state) => {
	// 缓存购物车数据
	uni.setStorageSync('carList', state.car.carList)
})

export default store